package com.gxl.design.commandpattern.order;

import com.gxl.design.commandpattern.AbstractOperater;

import java.util.ArrayList;
import java.util.List;

public class Orders {

    private List<AbstractOperater> list = new ArrayList<>();

    public void insertOrder(AbstractOperater operater) {
        list.add(operater);
    }

    public void excuteOrders() {
        for (AbstractOperater operator : list) {
            operator.doOperator();
        }
    }

    /**
     * 命令集
     * @return
     */
    public String addOne(){
        System.out.println("  +1  ");
        return "1";
    }

    public String subtractTwo(){
        System.out.println("  -2  ");
        return "2";
    }

    public String multiplyThree(){
        System.out.println("  *3  ");
        return "3";
    }

    public String divideFour(){
        System.out.println("  /4  ");
        return "4";
    }

}
